<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    ref="childModal"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <template slot="footer" v-if="footer">
      <a-button @click="handleCancel">关闭</a-button>
      <a-button type="primary" :loading="confirmLoading" @click="handleOk">确定</a-button>
    </template>
    <tb-teacher-work-check-table-form ref="realForm" @modelLoading="getConfirmLoading" @ok="submitCallback" :disabled="disableSubmit"></tb-teacher-work-check-table-form>
  </j-modal>
</template>

<script>

  import TbTeacherWorkCheckTableForm from './TbTeacherWorkCheckTableForm'
  export default {
    name: 'TbTeacherWorkCheckTableModal',
    components: {
      TbTeacherWorkCheckTableForm
    },
    data () {
      return {
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        confirmLoading: false,
        footer:true
      }
    },
    methods: {
      getConfirmLoading(data){
        this.confirmLoading = data;
      },
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.footer = true;
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          if (record.classId) {
            this.footer = false;
          }
          this.$refs.childModal.toggleFullscreen();
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>